package com.kuyu.enums;

import lombok.Getter;
//枚举类定义
//enum
//常量名(key,value),
@Getter
public enum ProductStatusEnum {
    UP(0,"在架"),
    DOWN(1,"下架"),
    ;
    private Integer code;
    private String message;

    ProductStatusEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    // 普通方法:根据索引找到对应名称
    public static String getName(int index) {
        for (ProductStatusEnum c : ProductStatusEnum.values()) {
            if (c.getCode() == index) {
                return c.getMessage();
            }
        }
        return null;
    }
}
